package exer;

/**
 * @author shkstart
 * @create 2022-08-14-15:54
 */
public class Num876 {
    public ListNode middleNode(ListNode head) {

//        int size =0;
//        ListNode perv= head;
//        while (perv != null) {
//            perv = perv.next;
//            size++;
//        }
//        for (int i = 0; i < size / 2; i++) {
//            head = head.next;
//        }
//        return head;
        ListNode low = head;
        ListNode high =head;
        while (high!=null&&high.next!=null){
            low = low.next;
            high = high.next.next;
        }
        return low;
    }
}
